<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组</title>
</head>
<body>
<script>
    // 创建指定长度的数组
    let arr1 = new Array(5);
    arr1[0] = 'a';
    arr1[1] = 'b';
    arr1[2] = 'c';
    arr1[3] = 'd';
    arr1[4] = 'e';
    arr1[5] = 'f';
    arr1.length = 10;
    console.log(arr1);
    console.log(arr1.length);

    //创建一个空数组
    let arr2 = new Array();
    arr2[0] = 'a';
    arr2[3] = 'a';
    //push() 在数组的最后继续添加元素
    arr2.push('b');
    arr2.push('c', 'd');
    console.log(arr2);

    //创建一个数组，指定数组中的元素
    let arr3 = new Array('a', 'b', 'c', 'd');
    console.log(arr3);
    let arr4 = ['a', 'b', 'c', 'd', 'e', 'f'];
    console.log(arr4);
    for (let i = 0; i < arr4; i++) {
        console.log(arr4[i]);
    }
    //pop()弹出数组中的最后一个元素
    let v = arr4.pop();
    console.log(v);
    console.log(arr4);
    //splice(a,b)删除数组中指定下标的元素;a-下标，b-删除的个数
    arr4.splice(3, 1);
    console.log(arr4);
</script>
</body>
</html>